<template>
    <el-dialog :title="this.$root.lang.control.block.detail.title" :visible.sync="showDialog" @close="closeDialog" width="50%"  :close-on-click-modal="false" :close-on-press-escape="false">
      <el-form @submit.native.prevent class="change-password" ref="form" size="small" label-position="right" label-width="140px">
        <el-form-item :label="getLabel('ledgerHash')">
          <span>{{ detail.ledgerHash }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('height')">
          <span>{{ detail.height }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('hash')">
          <span>{{ detail.hash }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('previousHash')">
          <span>{{ detail.previousHash }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('transactionSetHash')">
          <span>{{ detail.transactionSetHash }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('contractAccountSetHash')">
          <span>{{ detail.contractAccountSetHash }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('dataAccountSetHash')">
          <span>{{ detail.dataAccountSetHash }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('systemEventSetHash')">
          <span>{{ detail.systemEventSetHash }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('userAccountSetHash')">
          <span>{{ detail.userAccountSetHash }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('timestamp')">
          <span>{{ detail.timestamp }}</span>
        </el-form-item>
        <el-form-item :label="getLabel('dataDetails')">
          <span>{{ detail.dataDetails }}</span>
        </el-form-item>
      </el-form>
    </el-dialog>
</template>

<script>
export default {
  name: 'BlockDetail',
  data() {
    return {
    	loading: false,
    	showDialog: this.show,
    }
  },
  watch: {
    show: function (value) {
      this.showDialog = value
  	},
  },
  props: {
  	show: {
      type: Boolean,
      default: false
    },
    detail: {
      type: Object,
      default: {}
    }
  },
  methods: {
    getLabel(name) {
      return this.$root.lang.control.block.detail[name]+'：'
    },
  	closeDialog() {
      this.$emit('editReceive',{
        key: 'showDetail',
        value: this.showDialog
      })
    },
  	editInfo () {
      this.loading = true
      this.request({
        url: '/blockchain/stock/apply/use',
        method: 'get',
      }).then(response => {
        this.loading = false
        this.$message({
          message:  this.$root.lang.confirm.buySuccess,
          type: 'success',
          duration: 3 * 1000
        })
        this.showDialog = false
				this.$emit('reload')
      }).catch(error => {
        this.loading = false
        this.$message({
          message: error.errmsg,
          type: 'error',
          duration: 3 * 1000
        })
      })
    },
  },
  created() {
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>

</style>